<%-- 
    Document   : CheckOut
    Created on : May 17, 2012, 1:36:20 PM
    Author     : Alex

    CheckOut, where we find out what pay is due to the till.
--%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<%@page import="store.ShopInventory"%>
<%@page import="beans.Customer, java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<f:view>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Check Out</title>
    </head>
    <body BGCOLOR="#FFFFFF" TEXT="#000000">
        <font FACE=VERDANA></font>
    <center>
        <h2>Thank you, <h:outputText id="name" value="#{customerBean.name}" />, for shopping
            at this Store.</h2>

        <jsp:useBean id="customerBean" class="beans.Customer" scope="session"></jsp:useBean>
        <h:dataTable id="boughtItems"
                     border="1"
                     captionClass="list-caption"
                     columnClasses="list-column-center, list-column-left,
                     list-column-right, list-column-center"
                     footerClass="list-footer"
                     headerClass="list-header"
                     rowClasses="list-row-even, list-row-odd"
                     styleClass="list-background"
                     summary="A summary"
                     value="#{customerBean.cartItemBeans}"
                     var="item"
                     >
            
            <h:column headerClass="list-header-left">
                <f:facet name="header">
                    <h:outputText value="Quantity" />
                </f:facet>
                <h:outputText value="#{item.quantity}" />
            </h:column>
            <h:column headerClass="list-header-center">
                <f:facet name="header">
                    <h:outputText value="Item"/>
                </f:facet>
                <h:outputText value="#{item.name}" />
            </h:column>
            <h:column headerClass="list-header-center">
                <f:facet name="header">
                    <h:outputText value="Price"/>
                </f:facet>
                <h:outputText id="price" value="#{item.price}">
                    <f:convertNumber type="currency" />
                </h:outputText>
            </h:column>
            <h:column headerClass="list-header-right">
                <f:facet name="header">
                    <h:outputText value="Total"/>
                </f:facet>
                <h:outputText value="#{item.price * item.quantity}">
                    <f:convertNumber type="currency"/>
                </h:outputText>
            </h:column>
        </h:dataTable>
            <h:outputText value="Your total comes to $"/> <h:outputText value="#{customerBean.total}" />
            <br />
            <h:outputText value="Your groceries will be delivered to #{customerBean.address}" />
            <br />
            <h:outputText value="We accept money, gold, and otherworldly minerals." />
    </center>
    </body>
</html>
</f:view>